package unit4.part12.parking;

public class ParkingSystem {
    private CarCounter[] carCounters;

    public ParkingSystem(String str) {
        String[] strs = str.split(";");
        this.carCounters = new CarCounter[strs.length];
        for (int i = 0; i < strs.length; i++) {
            carCounters[i] = new CarCounter(strs[i]);
        }
    }

    public boolean addCar(CarType carType) {
        for (CarCounter counter : carCounters) {
            if (counter.getCarType() == carType) {
                return counter.decrease();
            }
        }
        return false;
    }
}
